Feat: Add ExtraFields support to OpenAI providers for custom parameters#45
Feat: Add ExtraFields support to OpenAI providers for custom parameters#45Jesssullivan wants to merge 70 commits intocharmbracelet:mainfrom
Conversation
…rs (#1) Adds support for arbitrary extra fields in OpenAI and OpenAI-compatible providers to enable custom parameters required by OpenAI-compatible APIs like Z.AI GLM. The OpenAI Go SDK's ChatCompletionNewParams provides a SetExtraFields() method, but Fantasy had no way to utilize it. This change adds an ExtraFields field to ProviderOptions and calls SetExtraFields() when extra fields are present. Use case: Custom OpenAI-compatible APIs (like Z.AI GLM) require additional parameters such as thinking mode configuration that aren't part of OpenAI's API spec: ```json { "extra_fields": { "thinking": { "budget_tokens": 26214, "type": "enabled" } } } ``` Changes: - Add \`ExtraFields map[string]any\` field to ProviderOptions in both openai and openaicompat providers - Call \`params.SetExtraFields()\` in PrepareCallFunc when ExtraFields present - Minimal, non-breaking change using omitempty JSON tag This enables Crush (charmbracelet/crush#1171) and other Fantasy consumers to pass custom parameters to OpenAI-compatible APIs without modifying Fantasy for each specific API's custom fields. Tested: Build successful, no breaking changes to existing functionality. Co-authored-by: OutBot CI <outbot@ci.gitlab.com>
|
Hey @Jesssullivan I think I already have it setup to work as expected in crush charmbracelet/crush@6bb85dc#diff-53bdf62a2aac11b071b4d3138352d3e902a49cf41c52ed86bf68d39177a86ebdR529 I just pushed a commit today. |
Rad! thanks. I think these are complimentary additions actually, though I may be wrong (still wending around the Fantasy layer). In charmbracelet/crush@6bb85dc#diff-53bdf62a2aac11b071b4d3138352d3e902a49cf41c52ed86bf68d39177a86ebdR529, openaisdk.WithJSONSet() can inject JSON fields directly into SDK requests. This would mean these injections occur on provider creation, not per call. In this PR, we're adding a discreet ExtraFields mechanism, which works per-call rather than just at provider creation. |
…s file if it does not already exist
Configure GitLab CI for Fantasy SDK institutional fork with RenovateBot and private module access. ## Changes ### .gitlab-ci.yml (NEW) - Add sync job for upstream charmbracelet/fantasy main branch - Add RenovateBot job for dependency automation - Add build and test jobs with private module support - Configure Go 1.24 build environment ### .gitlab/ci/go-private-modules.yml (NEW) - Configure GOPRIVATE, GONOSUMDB, GONOPROXY for gitlab.com/tinyland/* - Set up Git authentication with CI_JOB_TOKEN - Create .netrc for Go module downloads - Provide reusable .go_private_modules_setup mixin ### .gitlab/renovate.json (NEW) - Track OpenAI, Anthropic, AWS, GCP provider SDKs - Group Charmbracelet ecosystem updates - Configure automated dependency dashboard - Set review requirements for major updates ## Integration This complements the RenovateBot K8s deployment and enables Fantasy SDK to be consumed as a private module by downstream projects (Crush, etc.) within the tinyland namespace. 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
feat: Add full Fantasy SDK with CI/CD See merge request tinyland/ai/fuzzy-fantasy!2
The validate stage does not exist, causing all pipelines to fail. Changed go-mod-verify job to use the test stage instead. This fixes all failing CI runs. 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
go.mod requires Go 1.24.5 but go-private-modules.yml had hardcoded 1.23. Updated all golang:1.23 images → golang:1.24 to match go.mod requirement. 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
fix(deps): update module github.com/openai/openai-go/v2 to v3.6.1 See merge request tinyland/ai/fuzzy-fantasy!6
fix(deps): update charmbracelet packages See merge request tinyland/ai/fuzzy-fantasy!3
fix(deps): update gopkg.in/dnaeon/go-vcr.v4 digest to 3f65415 See merge request tinyland/ai/fuzzy-fantasy!4
fix(deps): update module github.com/aws/aws-sdk-go-v2 to v1.39.4 See merge request tinyland/ai/fuzzy-fantasy!5
…dule path - Updates github.com/charmbracelet/anthropic-sdk-go to newer pseudo-version - Removes replace directive for anthropic-sdk-go (no longer needed) - Keeps replace directive for go-genai pointing to google.golang.org/genai - Fixes CI build failures caused by module path mismatches
Merges upstream/main to incorporate bedrock-related fixes: - fix(bedrock): update anthropic sdk with fix for bedrock auth (e058884) - fix(bedrock): prefix model id with region automatically (ed9a9b8) - Release v0.1.1 (5260f37) Dependencies updated to upstream versions: - anthropic-sdk-go: v0.0.0-20251024181547 - go-genai: v0.0.0-20251021165952 - x/exp/slice: v0.0.0-b4e2667e5ad5 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Adds auto-merge configuration for non-breaking dependency updates: - Digest updates: auto-merge when CI passes - Minor updates: auto-merge when CI passes - Patch updates: auto-merge when CI passes - Major updates: continue to require manual review This reduces manual overhead while maintaining safety for breaking changes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
chore: sync upstream fantasy bedrock fixes See merge request tinyland/ai/fuzzy-fantasy!9
fix(deps): update module github.com/openai/openai-go/v2 to v3.6.1 See merge request tinyland/ai/fuzzy-fantasy!7
…nto 'main' fix(deps): update github.com/charmbracelet/x/exp/slice digest to dc9e594 See merge request tinyland/ai/fuzzy-fantasy!21
fix(deps): update module github.com/openai/openai-go/v2 to v3.8.1 See merge request tinyland/ai/fuzzy-fantasy!14
fix(deps): update module go.yaml.in/yaml/v4 to v4.0.0-rc.3 See merge request tinyland/ai/fuzzy-fantasy!24
fix(deps): update module golang.org/x/oauth2 to v0.33.0 See merge request tinyland/ai/fuzzy-fantasy!25
…nto 'main' fix(deps): update github.com/charmbracelet/x/exp/slice digest to 3bf63bc See merge request tinyland/ai/fuzzy-fantasy!23
fix(deps): update module github.com/openai/openai-go/v2 to v3.8.1 See merge request tinyland/ai/fuzzy-fantasy!22
…nto 'main' fix(deps): update github.com/charmbracelet/x/exp/slice digest to cef867b See merge request tinyland/ai/fuzzy-fantasy!26
fix(deps): update gopkg.in/dnaeon/go-vcr.v4 digest to 01de4eb See merge request tinyland/ai/fuzzy-fantasy!27
fix(deps): update module github.com/aws/aws-sdk-go-v2 to v1.40.0 See merge request tinyland/ai/fuzzy-fantasy!30
…nto 'main' fix(deps): update github.com/charmbracelet/x/exp/slice digest to 77d0172 See merge request tinyland/ai/fuzzy-fantasy!29
- Added complete glab CLI documentation with essential commands - Included CI/CD build debugging suite with 6-phase approach - Documented common failure patterns and solutions - Added emergency procedures and prevention strategies - Covers Go module sync issues, dependency updates, and pipeline monitoring
CI Improvements: - Enhanced go-mod-verify job to intelligently handle dependency updates - Added dedicated lint job with golangci-lint v2 installation - Fixed golangci-lint version compatibility issues Development Tooling: - Added Taskfile.yml with standardized development commands - Created intelligent pre-commit hook for CI failure prevention - Added scripts for pipeline debugging and local CI simulation Key Features: - Pre-commit hook detects and suggests fixes for go.mod/go.sum changes - Task-based workflow with build, test, lint, and CI verification - Docker-based local testing to simulate CI environment - Automated tool installation and environment setup This addresses the CI failures identified in MR #14 and provides a robust framework for preventing similar issues in the future.
- Automated installation of golangci-lint v2, task CLI, and dev tools - Pre-commit hook installation - Verification of all installations - Quick start commands reference 💘 Generated with Crush Co-Authored-By: Crush <crush@charm.land>
- Apply deterministic test changes from e3ab59b - Add automatic test detection for Google auth (flag.Lookup("test.v")) - Remove non-deterministic test data (Opus models, BasicAuth tests) - Fix all remaining linting issues (errcheck, gosimple) - Improve test reliability with t.Setenv for AWS region 💘 Generated with Crush Co-Authored-By: Crush <crush@charm.land>
- Document analysis of bedrock-fix branch commits - Categorize changes by risk level (safe/medium/high) - Confirm safe fixes already applied (deterministic tests, Google auth) - Plan separate effort for major SDK migration - Maintain repository stability while planning future improvements
- github.com/charmbracelet/x/exp/slice: 77d0172 -> 1dbcd82 - gopkg.in/dnaeon/go-vcr.v4: v4.0.6-0.20251110073552-01de4eb40290 -> v4.0.6 All tests pass, no lint issues. 💘 Generated with Crush Co-Authored-By: Crush <crush@charm.land>
…improvements Major features added: - Structured output support with new object package and JSON schema generation - Improved tool execution with parallel processing and better queuing - Azure reasoning models support (o4-mini, gpt-5, grok-3-mini) - Enhanced error handling and ProviderError serialization - VCR migration to charm.land/x/vcr - Google model reasoning handling improvements - OpenAI compatibility improvements Technical changes: - Added 95+ new files for structured output across all providers - Comprehensive test coverage with VCR recordings - New examples/structured-outputs demonstration - Provider registry functionality - JSON serialization support for models and content Preserves our custom CI/CD improvements and bedrock fixes while gaining full upstream feature parity. 💘 Generated with Crush Co-Authored-By: Crush <crush@charm.land>
- Sync dependencies after recent changes - Ensure module consistency across examples
This PR adds
ExtraFieldssupport to Fantasy'sopenaiandopenaicompatproviders, enabling custom parameters for OpenAI-compatible APIs that require fields beyond the standard OpenAI specification.Changes
Added
ExtraFields map[string]anytoProviderOptionsin both providers:providers/openai/provider_options.goproviders/openaicompat/provider_options.goThe extra fields are applied via
params.SetExtraFields()in the respective hook functions:providers/openai/language_model_hooks.goproviders/openaicompat/language_model_hooks.goUse Case: Z.AI GLM Thinking Mode
This enables passing custom parameters like Z.AI GLM's thinking mode configuration:
The extra fields are passed through to the OpenAI SDK's
SetExtraFields()method and included in the HTTP request to the provider API.Dependencies
Depends on: #41 (ZAI provider support)
Related
Relates to: charmbracelet/crush#1295 - Integration in Crush
CONTRIBUTING.md.